#pragma once

#include "protocol.hpp"

class NetCal
{
public:
    Response NetCalculation(Request &req)
    {
        std::cout << "---------req---------" << std::endl;
        std::cout << req.Getx() << std::endl;
        std::cout << req.Gety() << std::endl;
        std::cout << req.Getoper() << std::endl;
        std::cout << "---------------------------" << std::endl;
        Response lo_res;
        switch (req.Getoper())
        {
        case '+':
            lo_res.Setvalue(req.Getx() + req.Gety());
            break;
        case '-':
            lo_res.Setvalue(req.Getx() - req.Gety());
            break;
        case '*':
            lo_res.Setvalue(req.Getx() * req.Gety());
            break;
        case '/':
            if (req.Gety() == 0)
            {
                lo_res.Setcode(1);
            }
            else
            {
                lo_res.Setvalue(req.Getx() / req.Gety());
            }
            break;
        case '%':
            if (req.Gety() == 0)
            {
                lo_res.Setcode(2);
            }
            else
            {
                lo_res.Setvalue(req.Getx() % req.Gety());
            }
            break;
        default:
            lo_res.Setcode(3);
            break;
        }
        return lo_res;
    }

private:
};